package myapps.ttclient.protocol.message;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import myapps.ttclient.Helper;
import myapps.ttclient.baseclass_and_interface.TTClientMessage;
import myapps.ttclient.struct.FileDetailsStruct;

public class FileDetailsResponseMessage extends TTClientMessage {
	private FileDetailsStruct fileDetails = new FileDetailsStruct();
	
	public FileDetailsStruct getFileDetails() {
		return fileDetails;
	}

	public void setFileDetails(FileDetailsStruct fileDetails) {
		this.fileDetails = fileDetails;
	}

	public FileDetailsResponseMessage(FileDetailsStruct fileDetails) {
		this.fileDetails = fileDetails;
	}

	public static TTClientMessage parse(DataInputStream dis) throws IOException	{
		FileDetailsStruct fileDetails = new FileDetailsStruct();
		
		fileDetails.name = Helper.ParseAsString(dis);
		fileDetails.length = dis.readLong();
		fileDetails.directoryFullPath = Helper.ParseAsString(dis);
		fileDetails.creationTime = Helper.ParseAsString(dis);
		fileDetails.lastAccessTime = Helper.ParseAsString(dis);
		fileDetails.lastWriteTime = Helper.ParseAsString(dis);
		
		return new FileDetailsResponseMessage(fileDetails);
	}

	@Override
	public void toDataOutputStream(DataOutputStream dos) throws IOException	{
		throw new IOException("NotImplementedException");
	}
}